package czk.jvm.lecture.bytecode;

public class MyTest4 {
    public void test(Grandpa grandpa){
        System.out.println("grandpa");
    }
    public void test(Father father){
        System.out.println("father");
    }
    public void test(Son son){
        System.out.println("son");
    }
    public static void main(String[] args) {
        //g1的静态类型为grandpa,而执行哪个重载方法，则是通过静态类型变量来确定的
        Grandpa g1=new Grandpa();
        Father g2=new Father();
        Grandpa g3=new Son();
        MyTest4 myTest4=new MyTest4();
        myTest4.test(g1);
        myTest4.test(g2);
        myTest4.test(g3);
    }
}
class Grandpa{

}
class Father extends Grandpa{

}
class Son extends Father{

}
